#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul  6 12:34:03 2018

@author: lishuang
"""


import json
import os
import pandas as pd

os.chdir('/Users/lishuang/Documents/lishuang/项目文档/烟商贷/模型测试/内测期间验证/')

f = open('唐小红.json')

mydata = json.load(f)

mydf_indent = mydata['indent'] #定烟记录

detail_all = pd.DataFrame()
tmpall = pd.DataFrame()
result = pd.DataFrame()


for i in range(0, len(mydf_indent)): #每一次定烟总记录
    tmp = mydf_indent[i]
    tmp = pd.DataFrame(tmp)
    ind = 0
    for j in range(0, tmp.shape[0]):
        
        detail = pd.DataFrame(tmp.iloc[j]['indentDetails'],index=[0])
        detail['indentAccount'] = tmp.iloc[j]['indentAccount']
        detail['indentDate'] = tmp.iloc[j]['indentDate']
        detail['indentMoney'] = tmp.iloc[j]['indentMoney']
        detail['indentNum'] = tmp.iloc[j]['indentNum']
        detail['accountNum'] = mydata['accountNum']
        detail['custSize'] = mydata['custSize']
        detail['gear'] = mydata['gear']
        detail['seq'] = ind
        ind = ind +1
        detail_all = pd.concat([detail_all, detail])

detail_all.to_excel('唐小红.xls')